import request from '@/utils/http'
// -----------------------------------------------------------------------班组维护页面-------------------------------------------------------
// 提交班次
export function banZuTiJiao(data) {
  return request.request({
    url: '/api/v3.1/business/class-time-table/batch-insert',
    method: 'post',
    data
  })
}
// 指定车间，指定工序，获取指定日期范围下整个车间的换班方式
export function cheJianHuanBanList(data) {
  return request.request({
    url: '/api/v3.1/business/class-time-table/ui?DateStartInput=' + data.DateStartInput,
    method: 'get'
  })
}

// 提交按天排班数据
export function postPaiBanHttp(data) {
  return request.request({
    url: '/api/v3.1/business/class-table/batch',
    method: 'post',
    data
  })
}

// 提交按月排班数据
export function postPaiBanMonthHttp(data) {
  return request.request({
    url: '/api/v3.1/business/class-table/batch-month',
    method: 'post',
    data
  })
}

//  根据工艺节点、年、月 查询排班记录
export function getPaiBanJiLvList(param) {
  return request.request({
    url:
      '/api/v3.1/business/class-table/month-report?CraftNodeListGuid=' +
      param.CraftNodeListGuid +
      '&Year=' +
      param.Year +
      '&Month=' +
      param.Month,
    method: 'get'
  })
}

// -----------------------------------------------------------------------品种维护 - 物料设定-------------------------------------------------------

//  根据工艺节点获取机台实时展现数据
export function getJiTaiList(GongXuId) {
  return request.request({
    url: '/api/v3.1/business/device-info/machine-macterial-by-craftnode/' + GongXuId,
    method: 'get'
  })
}

//  新建物料记录
export function postWuLiaoJiLv(data) {
  return request.request({
    url: '/api/v3.1/business/material',
    method: 'post',
    data
  })
}

//  修改物料记录
export function deleteWuLiao(MaterialId) {
  return request.request({
    url: '/api/v3.1/business/material?materialId=' + MaterialId,
    method: 'delete'
  })
}

//  修改物料记录
export function postGengXinWuLiao(data, MaterialId) {
  return request.request({
    url: '/api/v3.1/business/material?MaterialId=' + MaterialId,
    method: 'put',
    data
  })
}

//  指定工序，模糊查询名称 获取物料列表
export function getWuLiaoList(GongXuId, name) {
  return request.request({
    url: '/api/v3.1/business/material/material-info?CraftNodeGuid=' + GongXuId + '&name=' + name,
    method: 'get'
  })
}

//  指定工艺节点列表，获取所有备选的物料信息-UI
export function postBeiXuanWuLiaoXinXi(data) {
  return request.request({
    url: '/api/v3.1/business/material/material-info-by-craft-node-ids',
    method: 'post',
    data
  })
}

//  新增机台调度记录
export function postXingZengJiTai(data) {
  return request.request({
    url: '/api/v3.1/business/process-dispatch-queue/not-order',
    method: 'post',
    data
  })
}

//  查询更换记录
export function getJiTaiList1(data) {
  return request.request({
    url: '/api/v3.1/business/process-dispatch-queue/process-dispatch-queue-update-record',
    method: 'post',
    data
  })
}
// -----------------------------------------------------------------------品种维护 - 配比设定-------------------------------------------------------

//  根据车间id获取工艺和品种对应关系
export function getGongYiAndPingZhong() {
  return request.request({
    url: '/api/v3.1/business/material/node-materials?days=' + 60,
    method: 'get'
  })
}

//  获取指定工艺节点的所有前道节点与品种Tree
export function getHuoQuPingZhongTree(param) {
  return request.request({
    url: '/api/v3.1/business/material/pre-node-materials?CraftID=' + param.CraftID,
    method: 'get'
  })
}

//  获取已经存在的前道配比
export function getQianDaoPeiBi(param) {
  return request.request({
    url: '/api/v3.1/business/material/pre-node-info?MaterialGuid=' + param.MaterialGuid,
    method: 'get'
  })
}

//  新增机台调度记录
export function postXingZengPeiBi(data) {
  return request.request({
    url: '/api/v3.1/business/material/craftflow-record',
    method: 'post',
    data
  })
}

//  获总结构图
export function getZongJieGouTu() {
  return request.request({
    url: '/api/v3.1/business/material/node-material',
    method: 'get'
  })
}

//  指定工序下物料的所有前道物料图
export function getTeDingJieGouTu(data) {
  return request.request({
    url: '/api/v3.1/business/material/pre-node-material?MaterialGuid=' + data.MaterialGuid,
    method: 'get'
  })
}
//  指定工序下物料的所有前道物料图
export function getGongXuCanShu(name) {
  return request.request({
    url: '/api/v3.0/basic/collect-meta/collect-meta-with-census-list?craftNodeName=' + name,
    method: 'get'
  })
}

//  获取参数上下限当前设置信息
export function getCanShuShangXiaXian(craftNodeId) {
  return request.request({
    url: '/api/v3.1/business/parameter-limit/parameter-limit/' + craftNodeId,
    method: 'get'
  })
}

//  修改参数上下限设置
export function putCanShuShangXiaXian(data) {
  return request.request({
    url: '/api/v3.1/business/parameter-limit/parameter-limit',
    method: 'put',
    data
  })
}

//  删除参数上下限设置
export function deleteCanShuShangXiaXian(data) {
  return request.request({
    url:
      '/api/v3.1/business/parameter-limit/parameter-limit?machineDocumentId=' +
      data.machineDocumentId +
      '&parameterLimitId=' +
      data.parameterLimitId,
    method: 'delete'
  })
}

//  新增参数上下限设置
export function postCanShuShangXiaXian(data) {
  return request.request({
    url: '/api/v3.1/business/parameter-limit/parameter-limit',
    method: 'post',
    data
  })
}

/**
 * 指定是否为当前对应关系、班次，查询E系统品种与第三方品种对应关系
 * type 区分 第三方与打包机
 * /api/v3.1/business/material-and-baler-asso/baler-material-assos
 */
export function getDuiYingGuanXi(data, type) {
  const url =
    type === 'roving-yarn'
      ? 'material-and-third-asso/cxl-material-assos'
      : 'material-and-baler-asso/baler-material-assos'
  return request.request({
    url:
      `/api/v3.1/business/${url}?isCurrent=` +
      data.isCurrent +
      '&tsidStart=' +
      data.tsidStart +
      '&tsidEnd=' +
      data.tsidEnd,
    method: 'get'
  })
}

// //  指定是否为当前对应关系、班次，查询E系统品种与第三方品种对应关系
// export function getDiSanFangDuiYingGuanXi(data) {
//   return request.request({
//     url:
//       '/api/v3.1/business/material-and-third-asso/cxl-material-assos?isCurrent=' +
//       data.isCurrent +
//       '&tsidStart=' +
//       data.tsidStart +
//       '&tsidEnd=' +
//       data.tsidEnd,
//     method: 'get'
//   })
// }
//  查询粗细联品种
export function getChaXunCuXiLianPingZhong() {
  return request.request({
    url: '/api/v3.1/business/material-and-third-asso/cxl-material',
    method: 'get'
  })
}
//  新增粗细联品种对应关系
export function postDiSanFangPingZhongDuiYingGuanXi(data) {
  return request.request({
    url: '/api/v3.1/business/material-and-third-asso/update-cxl-material-asso',
    method: 'post',
    data
  })
}
//  更新粗细联品种
export function postGengXingCuXiLianPingZhong(data) {
  return request.request({
    url: '/api/v3.1/business/material-and-third-asso/update-cxl-material-dto',
    method: 'post',
    data
  })
}

//  终止当前品种对应关系
export function postZongZhiDangQianDuiYingGuanXi(id) {
  return request.request({
    url: '/api/v3.1/business/material-and-third-asso/' + id + '/terminate-material-and-third-asso',
    method: 'post'
  })
}
//  删除粗细联品种
export function deleteCuXiLianPingZhong(id) {
  return request.request({
    url: '/api/v3.1/business/material-and-third-asso/' + id + '/cxl-material',
    method: 'delete'
  })
}

//  更新打包机品种
export function postGengXingDaBaoJiPingZhong(data) {
  return request.request({
    url: '/api/v3.1/business/material-and-baler-asso/update-baler-material-dto',
    method: 'post',
    data
  })
}

//  查询打包机品种
export function getChaXunDaBaoJiPingZhong() {
  return request.request({
    url: '/api/v3.1/business/material-and-baler-asso/baler-material',
    method: 'get'
  })
}

//  删除打包机品种
export function deleteDaBaoJiPingZhong(id) {
  return request.request({
    url: '/api/v3.1/business/material-and-baler-asso/' + id + '/baler-material',
    method: 'delete'
  })
}

//  新增打包机品种对应关系
export function postDaBaoJiPingZhongDuiYingGuanXi(data) {
  return request.request({
    url: '/api/v3.1/business/material-and-baler-asso/update-baler-material-asso',
    method: 'post',
    data
  })
}

// //  指定是否为当前对应关系、班次，查询E系统品种与打包机品种对应关系
// export function getDaBaoJiDuiYingGuanXi(data) {
//   return request.request({
//     url:
//       '/api/v3.1/business/material-and-baler-asso/baler-material-assos?isCurrent=' +
//       data.isCurrent +
//       '&tsidStart=' +
//       data.tsidStart +
//       '&tsidEnd=' +
//       data.tsidEnd,
//     method: 'get'
//   })
// }

//  打包机终止当前品种对应关系
export function postDaBaoJiZongZhiDangQianDuiYingGuanXi(id) {
  return request.request({
    url: '/api/v3.1/business/material-and-baler-asso/' + id + '/terminate-material-and-third-asso',
    method: 'post'
  })
}

//  指定日期，查询细纱生产日报统计信息
export function getChaXunXiShaRiBao(TsIdDay) {
  return request.request({
    url:
      '/api/v3.1/business/inventory-day-report-xs/machine-production-day-report-xs-statistics-list?TsIdDay=' +
      TsIdDay,
    method: 'get'
  })
}

//  查询所有设备属性
export function getChaXunAllSheBeiShuXing() {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/machine-property',
    method: 'get'
  })
}

//  新增或修改设备属性，按机台设定
export function postXingZengXiuGaiSheBeiShuXing_jt(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/machine-property',
    method: 'post',
    data
  })
}

//  新增或修改设备属性，按机型设定
export function postXingZengXiuGaiSheBeiShuXing_jx(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/machine-property-by-machine-type',
    method: 'post',
    data
  })
}

//  指定机台id，删除设备属性
export function deleteSheBeiShuXing(id) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/machine-property/' + id,
    method: 'delete'
  })
}

//  新增或修改生产计划设置
export function postXingZengXiuShengChanJiHuaSheZhi(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/update-production-plan-set-xs-list',
    method: 'post',
    data
  })
}

//  查询生产计划设置
export function getChaXunAllShengChanSheZhi(data) {
  if (data.currentFlag == true) {
    return request.request({
      url:
        '/api/v3.1/business/inventory-day-report-xs/production-plan-set-xs?currentFlag=' +
        data.currentFlag,
      method: 'get'
    })
  } else {
    return request.request({
      url:
        '/api/v3.1/business/inventory-day-report-xs/production-plan-set-xs?currentFlag=' +
        data.currentFlag +
        '&begin=' +
        data.begin +
        '&end=' +
        data.end,
      method: 'get'
    })
  }
}

//  新增或修改细纱月生产计划
export function postXingZengXiuShengXiShaYueShengChanJiHua(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/update-production-plan-month-set-xs',
    method: 'post',
    data
  })
}

//  指定月份，查询细纱月生产计划
export function getXiShaYueShengChanJiHua(month) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/production-plan-month-set-xs?month=' + month,
    method: 'get'
  })
}

/**
 * 查询细纱机有几种锭数
 */
export function getXiShaJiDingShuZhongLei() {
  return request.request({
    url: '/api/v3.1/business/device-info/spindles-xs',
    method: 'get'
  })
}

/**
 * 指定年份，查询月报设置
 */
export function getPanCunYueBaoSheZhi(year) {
  return request.request({
    url: '/api/v3.1/business/intenvory-month-report-set/intenvory-month-report-set?year=' + year,
    method: 'get'
  })
}

//  新增或修改月报设置
export function postXingZengXiuShengPanCunYueBaoSheZhi(data) {
  return request.request({
    url: '/api/v3.1/business/intenvory-month-report-set/update-intenvory-month-report-set',
    method: 'post',
    data
  })
}

/**
 * 指定日期，查询细纱日生产计划
 */
export function getXiShaRiShengChanJiHua(tsidDay) {
  return request.request({
    url:
      '/api/v3.1/business/inventory-day-report-xs/production-plan-month-set-xs?tsidDay=' + tsidDay,
    method: 'get'
  })
}

//  新增或修改细纱日生产计划
export function postXingZengXiuShengXiShaRiShengChanJiHua(data) {
  return request.request({
    url: '/api/v3.1/business/inventory-day-report-xs/update-production-plan-month-set-xs',
    method: 'post',
    data
  })
}

//  指定物料id，查询该物料是否被改纺过
export function postShiFouBeiXiuGai(materialId) {
  return request.request({
    url: '/api/v3.1/business/material/is-has-process-dispatch-queue/' + materialId,
    method: 'post'
  })
}

//  新增清纱器报警设置
export function postQingShaQiBaoJinSheZhi(data) {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/uster-custom-alarm-set',
    method: 'post',
    data
  })
}

//  修改清纱器报警设置
export function putQingShaQiBaoJinSheZhi(data) {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/uster-custom-alarm-set',
    method: 'put',
    data
  })
}

//  查询清纱器报警设置
export function getQingShaQiBaoJinSheZhi() {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/uster-custom-alarm-set',
    method: 'get'
  })
}
//  指定id，删除清纱器报警设置
export function deleteQingShaQiBaoJinSheZhi(id) {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/' + id + '/uster-custom-alarm-set',
    method: 'delete'
  })
}

//  指定清纱器报警设置，编辑该报警设置是否有效
export function putQingShaQiBaoJinSheZhi_shiFouYouXiao(data) {
  return request.request({
    url:
      '/api/v3.1/business/uster-custom-alarm-set/' +
      data.id +
      '/enable-flag?enableFlag=' +
      data.enableFlag,
    method: 'put'
  })
}

//  编辑报警参数
export function postQingShaQiBaoCanShu(data) {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/update-uster-custom-alarm-param',
    method: 'post',
    data
  })
}

//  查询报警参数
export function getQingShaQiBaoJingCanShu() {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/uster-custom-alarm-param?collectMetaType=',
    method: 'get'
  })
}

//  指定id，删除报警参数
export function deleteQingShaQiBaoJingCanShu(id) {
  return request.request({
    url: '/api/v3.1/business/uster-custom-alarm-set/' + id + '/uster-custom-alarm-param',
    method: 'delete'
  })
}

//  根据班次查询络筒基础报表
export function postBanCiLuoTongJiChuBaoBiao(data) {
  return request.request({
    url: '/api/v3.1/business/machine-shift-report/basic-machine-shift-report-by-tsid-and-craft-node-id-lt',
    method: 'post',
    data
  })
}

//  根据工艺节点、班次、人员获取人员机台看台信息
export function getRenYuanKaiTaiXinXi(data) {
  return request.request({
    url:
      '/api/v3.1/business/duty-assign-history/device-person-info-by-person-and-tsid?craftNodeId=' +
      data.craftNodeId +
      '&tsid=' +
      data.tsid +
      '&personDocumentId=' +
      data.personDocumentId,
    method: 'get'
  })
}

//  更新络筒产量补录记录
export function postChanLiangBuLu_luoTong(data) {
  return request.request({
    url: '/api/v3.1/business/production-replacement/production-group-lt',
    method: 'post',
    data
  })
}

//  删除络筒班产记录
export function deleteLuoTongBanChanJiLu(id) {
  return request.request({
    url: '/api/v3.1/business/production-replacement/' + id + '/production-group-lt',
    method: 'delete'
  })
}

//  修改络筒产量
export function putXiuGaiLuoTongChanLiang(data) {
  return request.request({
    url: '/api/v3.1/business/production-replacement/production-group-lt',
    method: 'put',
    data
  })
}

//  获取络筒补录中-人员绩效产量
export function getLuoTongChanLiangBuLu_renYuan(data) {
  return request.request({
    url:
      '/api/v3.1/business/employee-scan/employee-performance-lt?tsIdStart=' +
      data.tsIdStart +
      '&tsIdEnd=' +
      data.tsIdEnd,
    method: 'get'
  })
}

//  获取灯控位置图(新版)
export function getDengKongWeiZhiTu_xingBan() {
  return request.request({
    url: '/api/v3.0/basic/light/light-location-new/' + '00000000-0000-0000-0000-000000000000',
    method: 'get'
  })
}

//  获取区域
export function getHuoQuQuYu() {
  return request.request<{ areaId: string; areaName: string; shiftChangeAreaCrafts: any }[]>({
    url: '/api/v3.1/business/shift-change-area-machine-asso/area-list',
    method: 'get'
  })
}

//  获取指定日期整个车间的换班方式记录-Ui
export function getcheJianHuanBanFangShi_qy(params) {
  return request.request({
    url: '/api/v3.1/business/class-time-area-table/ui?DateStartInput=' + params.DateStartInput,
    method: 'get'
  })
}

//  新增 换班方式-UI(按照区域)
export function postHuanBanFangShi_qy(data) {
  return request.request({
    url: '/api/v3.1/business/class-time-area-table/batch-area-insert',
    method: 'post',
    data
  })
}

//  新增排班记录
export function postXingZengPaiBanJiLu_qy(data) {
  return request.request({
    url: '/api/v3.1/business/class-area-table',
    method: 'post',
    data
  })
}

//  按天排班-Ui
export function postAnTianPaiBan_qy(data) {
  return request.request({
    url: '/api/v3.1/business/class-area-table/batch',
    method: 'post',
    data
  })
}

//  按月排班-Ui
export function postAnYuePaiBan_qy(data) {
  return request.request({
    url: '/api/v3.1/business/class-area-table/batch-month',
    method: 'post',
    data
  })
}

//  删除某个区域下、一段时期内的排班计划
export function deleteQuYuNeiPaiBaiBanJiHua_qy(id) {
  return request.request({
    url: '/api/v3.1/business/class-area-table/by-area-date/' + id,
    method: 'delete'
  })
}

//  根据区域id、开始结束日期，获取对应的排班记录
export function getHuoQuDuiYinDePaiBanJiLu_qy(params) {
  return request.request({
    url:
      '/api/v3.1/business/class-area-table/date/' +
      params.AreaId +
      '?StartDate=' +
      params.StartDate +
      '&EndDate=' +
      params.EndDate,
    method: 'get'
  })
}

//  获取区域下的月度排班记录
export function getHuoQuQuYuYueDuPaiBanJiLu_qy(params) {
  return request.request({
    url:
      '/api/v3.1/business/class-area-table/month-report/' +
      params.AreaId +
      '?Year=' +
      params.Year +
      '&Month=' +
      params.Month,
    method: 'get'
  })
}
